package com.project.class3_30;

import java.util.concurrent.*;

public class EatDumplings {
    public static int number=25;
    public static void main(String[] args) {
        ExecutorService es= Executors.newCachedThreadPool();
        es.execute(new Z());
        es.execute(new M());
        es.shutdown();
    }
}
class Z implements Runnable{
    @Override
    public void run() {
        int i=0;
        while (EatDumplings.number>0){
            EatDumplings.number--;
            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }i++;}
        System.out.println("大壮吃了"+i+" 个");
    }
}
class M implements Runnable{
    @Override
    public void run() {
        int i=0;
        while (EatDumplings.number>0){
            EatDumplings.number--;
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i++;
        }
        System.out.println("小明吃了"+i+" 个");
    }
}